package cn.nuc.teacher.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.nuc.common.utils.PageUtils;
import cn.nuc.common.utils.Query;

import cn.nuc.teacher.dao.TeacherDao;
import cn.nuc.teacher.entity.TeacherEntity;
import cn.nuc.teacher.service.TeacherService;


@Service("teacherService")
public class TeacherServiceImpl extends ServiceImpl<TeacherDao, TeacherEntity> implements TeacherService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TeacherEntity> page = this.page(
                new Query<TeacherEntity>().getPage(params),
                new QueryWrapper<TeacherEntity>()
        );

        return new PageUtils(page);
    }

  @Override
  public int check(TeacherEntity teacher) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("tid",teacher.getTid());
    queryWrapper.eq("tpassword",teacher.getTpassword());
    try{
      TeacherEntity teacherEntity = baseMapper.selectOne(queryWrapper);
      return teacherEntity.getT();
    }catch(Exception e){
      return -1;
    }
  }

}
